import axios from 'axios';

let instancepost =axios.create({
    headers:{
        'Content-Type':'application/json;charset=utf-8'
    },
    /* baseURL:"http://album.contest.mrs4s.moe:9998", */
    baseURL:"/api",//正向代理配置
    timeout:5000
})

export const sendActionPost=(url,data)=>{
    return new Promise((resolve,reject)=>{
        instancepost.request({
            url,
            data,
            method:"POST"
        }).then((res)=>{
            resolve(res)
        }).catch((err)=>{
            reject(err)
        })
    })
}

let instanceget =axios.create({
    headers:{
        'Content-Type':'application/json;charset=utf-8'
    },
    /* baseURL:"http://album.contest.mrs4s.moe:9998", */
    baseURL:"/api",//正向代理配置
    timeout:5000
})


export const sendActionGet=(url,params="")=>{
    return new Promise((resolve,reject)=>{
        instanceget.request({
            url,
            params,
            method:"GET"
        }).then((res)=>{
            resolve(res)
        }).catch((err)=>{
            reject(err)
        })
    })
}

export const sendActionDelete=(url)=>{
    return new Promise((resolve,reject)=>{
        axios.request({
            url:'/api'+url,
            method:"DELETE"
        }).then((res)=>{
            resolve(res)
        }).catch((err)=>{
            reject(err)
        })
    })
}